﻿using IT.CMS.Web.DataContext;
using IT.CMS.Web.Models.Aldarwaza;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace IT.CMS.Web.Controllers
{
    public class AldarwazaCommonController : BaseCmsController
    {
        //
        // GET: /AldarwazaCommon/
        public ActionResult Index()
        {
            return View();
        }



        [ChildActionOnly]
        public ActionResult Logo()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Home Banner
            // @* Select * from adver where ADVER_POSITION = 0 and Adver_Activate = true")*@
            _Aldarwaza_Adver banner = db._Aldarwaza_Advers.Where(adv => adv.Adver_Position == 0 && adv.Adver_Activate == true).FirstOrDefault();

            model.HomeBanner = banner;
            return PartialView(model);


        }


        [ChildActionOnly]
        public ActionResult News()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Produce News
            // select * from news where PRODUC_news=true order by Produc_ID Desc
            model.ProduceNews = db._Aldarwaza_News.Where(nes => nes.PRODUC_news == true).OrderByDescending(nes => nes.PRODUCT_ID).ToList();
            return PartialView(model);
        }

        
        [ChildActionOnly]
        public ActionResult Newsbar()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Home Hot News
            // select * from news where PRODUC_Hot=true  order by Produc_ID Asc
            model.HotNews = db._Aldarwaza_News.Where(nes => nes.PRODUC_Hot == true).OrderBy(nes => nes.PRODUC_ID).ToList();
            return PartialView(model);
        }

        [ChildActionOnly]
        public ActionResult Vedio()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Vedios
            // select * from news where PRODUCT_ID=12 and PRODUC_MP=true order by Produc_ID Asc
            model.VedioList = db._Aldarwaza_News.Where(nes => nes.PRODUCT_ID == 12 && nes.PRODUC_MP == true).OrderBy(nes => nes.PRODUCT_ID).ToList();
            return PartialView(model);
        }

        [ChildActionOnly]
        public ActionResult Headnews()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Main News
            // "select * from news where PRODUC_Main=true order by Produc_ID Desc"
            model.Headnews = db._Aldarwaza_News.Where(nes => nes.PRODUC_Main == true).OrderBy(nes => nes.PRODUCT_ID).ToList<_Aldarwaza_New>();

            return PartialView(model);
        }

        [ChildActionOnly]
        public ActionResult LeftSide()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Today Writes
            // select * from news where PRODUCT_ID=15 and PRODUC_MP=true order by Produc_ID Asc
            model.TodayWrites = db._Aldarwaza_News.Where(nes => nes.PRODUCT_ID == 15 && nes.PRODUC_MP == true).OrderBy(nes => nes.PRODUCT_ID).ToList<_Aldarwaza_New>();



            // Left Side Adds
            // Select * from adver where ADVER_POSITION = 3 and Adver_Activate = true
            model.HomeBanner = db._Aldarwaza_Advers.Where(adv => adv.Adver_Position == 3 && adv.Adver_Activate == true).FirstOrDefault();

            return PartialView(model);
        }


        [ChildActionOnly]
        public ActionResult RightSide()
        {
            AldarwazaDataContext db = new AldarwazaDataContext();
            PageContents model = new PageContents();

            // Deaths
            // select * from news where PRODUCT_ID=18 order by Produc_ID Asc
            model.Deaths = db._Aldarwaza_News.Where(nes => nes.PRODUCT_ID == 18).OrderBy(nes => nes.PRODUCT_ID).FirstOrDefault();



            // Right Side Adds Possiton(1)
            // Select * from adver where ADVER_POSITION = 1 and Adver_Activate = true
            model.HomeBanner_1 = db._Aldarwaza_Advers.Where(adv => adv.Adver_Position == 1 && adv.Adver_Activate == true).FirstOrDefault();


            // Right Side Adds Possiton(2)
            // Select * from adver where ADVER_POSITION = 1 and Adver_Activate = true
            model.HomeBanner_2 = db._Aldarwaza_Advers.Where(adv => adv.Adver_Position == 2 && adv.Adver_Activate == true).FirstOrDefault();

            return PartialView(model);
        }







    
    
    }
}
